package com.neusoft.repository.controller;

import com.alibaba.fastjson.JSON;
import com.neusoft.repository.entity.AddFormEntity;
import com.neusoft.repository.service.RepService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @program: repository
 * @description:
 * @author: dong.tl
 * @create: 2019-02-19 09:00
 **/
@Controller
public class RepController {

    private static Logger log = LoggerFactory.getLogger(RepController.class);

    @Autowired
    private RepService repService;

    @RequestMapping("/{page}")
    public String hello(Map<String, Object> map, @PathVariable("page") String page) {
        map.put("name", "大傻子");
        return page;
    }

    @RequestMapping(value = "/addDoc", method = RequestMethod.POST)
    @ResponseBody
    public Object addDoc(AddFormEntity form) {
        return repService.saveDoc(form);
    }

    @RequestMapping(value = "/search", method = RequestMethod.POST)
    @ResponseBody
    public Object search(String search_text, int page, int count) {
        return repService.search(search_text, page, count);
    }

    @RequestMapping(value = "/del", method = RequestMethod.POST)
    @ResponseBody
    public Object del(String id, String fileId) {
        return repService.del(id, fileId);
    }


}
